#!/bin/bash

set -ex

#define vars
SHELL_PATH=$(dirname $0)
export MTSQL_PT_FEATURE_PATH=$(cd ${SHELL_PATH}/../; pwd)
export MTSQL_PT_FEATURE_PATH_THREAD_POOL=${MTSQL_PT_FEATURE_PATH}/threadpool
export MTSQL_PT_FEATURE_PATH_THREAD_POOL_RESULT=${MTSQL_PT_FEATURE_PATH_THREAD_POOL}/result

source ${MTSQL_PT_FEATURE_PATH}/env.sh
source ${MTSQL_PT_FEATURE_PATH_THREAD_POOL}/benchmark_base_func.sh

##gen graph
#mtsql nothreadpool
if [ -z ${MTSQL_PT_DB_TYPE_SPEC} ] || ( [ ${MTSQL_PT_DB_TYPE_SPEC} == "mtsql" ] && [ ${MTSQL_PT_WITH_FEATURE_SPEC} == "0" ] );then
  export MTSQL_PT_DB_TYPE=mtsql
  export MTSQL_PT_WITH_FEATURE="0"
  python3 ${MTSQL_PT_FEATURE_PATH_THREAD_POOL_RESULT}/resultgraph_transaction_for_base.py
  python3 ${MTSQL_PT_FEATURE_PATH_THREAD_POOL_RESULT}/resultgraph_latency_for_base.py
fi

#mtsql threadpool
if [ -z ${MTSQL_PT_DB_TYPE_SPEC} ] || ( [ ${MTSQL_PT_DB_TYPE_SPEC} == "mtsql" ] && [ ${MTSQL_PT_WITH_FEATURE_SPEC} == "1" ] );then
  export MTSQL_PT_DB_TYPE=mtsql
  export MTSQL_PT_WITH_FEATURE="1"
  python3 ${MTSQL_PT_FEATURE_PATH_THREAD_POOL_RESULT}/resultgraph_transaction_for_base.py
  python3 ${MTSQL_PT_FEATURE_PATH_THREAD_POOL_RESULT}/resultgraph_latency_for_base.py
fi

#mariadb threadpool
if [[ -z ${MTSQL_PT_DB_TYPE_SPEC} || ${MTSQL_PT_DB_TYPE_SPEC} == "mariadb" ]]; then
  export MTSQL_PT_DB_TYPE=mariadb
  export MTSQL_PT_WITH_FEATURE="1"
  python3 ${MTSQL_PT_FEATURE_PATH_THREAD_POOL_RESULT}/resultgraph_transaction_for_base.py
  python3 ${MTSQL_PT_FEATURE_PATH_THREAD_POOL_RESULT}/resultgraph_latency_for_base.py
fi

#alisql threadpool
if [[ -z ${MTSQL_PT_DB_TYPE_SPEC} || ${MTSQL_PT_DB_TYPE_SPEC} == "alisql" ]]; then
  export MTSQL_PT_DB_TYPE=alisql
  export MTSQL_PT_WITH_FEATURE="1"
  python3 ${MTSQL_PT_FEATURE_PATH_THREAD_POOL_RESULT}/resultgraph_transaction_for_base.py
  python3 ${MTSQL_PT_FEATURE_PATH_THREAD_POOL_RESULT}/resultgraph_latency_for_base.py
fi

#txsql threadpool
if [[ -z ${MTSQL_PT_DB_TYPE_SPEC} || ${MTSQL_PT_DB_TYPE_SPEC} == "txsql" ]]; then
  export MTSQL_PT_DB_TYPE=txsql
  export MTSQL_PT_WITH_FEATURE="1"
  python3 ${MTSQL_PT_FEATURE_PATH_THREAD_POOL_RESULT}/resultgraph_transaction_for_base.py
  python3 ${MTSQL_PT_FEATURE_PATH_THREAD_POOL_RESULT}/resultgraph_latency_for_base.py
fi

